package licode.unisop.types.dp;

import org.springframework.util.Assert;

/**
 * 定义设备标识的元数据
 *
 * @author WR
 */
public class DeviceId {

    public static int MAX_SIZE = 64;

    public static final DeviceId DEFAULT = new DeviceId("DEFAULT");
    public static final DeviceId WEB = new DeviceId("WEB");
    public static final DeviceId APP = new DeviceId("APP");

    private final String id;

    private DeviceId(String id) {
        this.id = id;
    }

    public static DeviceId build(String id) {
        Assert.isTrue(DEFAULT.id.equals(id) ||
                        WEB.id.equals(id) ||
                        APP.id.equals(id),
                "非法的平台终端设备：" + id);
        return new DeviceId(id);
    }

    public boolean isApp() {
        return APP.id.equals(id);
    }

    public boolean isWeb() {
        return WEB.id.equals(id);
    }

    public String getId() {
        return id;
    }
}
